package com.zyf.school.manager.controller;

import com.zyf.school.manager.domain.Staff;
import com.zyf.school.manager.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/staff/")
public class StaffController {

    @Autowired
    StaffService staffService;

    @RequestMapping("staffManagerAddController")
    public String add(Staff staff,HttpServletRequest request){
        System.out.println("插入数据测试...........");
        staffService.insert(staff);
        return query(request);
    }
    @RequestMapping("staffManagerQuery")
    public String query(HttpServletRequest request){
        String tel = request.getParameter("tel");
        List<Staff> list = staffService.getStaffsByTel(tel);
        request.setAttribute("list",list);
        return "/staff/staffManager";
    }

    @RequestMapping("staffManagerQueryName")
    public String queryByName(HttpServletRequest request){
        String name = request.getParameter("name");
        List<Staff> list = staffService.getStaffsByName(name);
        request.setAttribute("list",list);
        return "/staff/staffManager";
    }
}
